
<html><HEAD>
<LINK REL=STYLESHEET HREF="default.css" TYPE="text/css">
<TITLE>
Sybase SQL Anywhere</TITLE>
</HEAD>
<BODY>

<!-- Header -->
<p class="ancestor" align="right"><A HREF="connpbp14.htm">Previous</A>&nbsp;&nbsp;<A HREF="connpbp16.htm" >Next</A>
<!-- End Header -->
<A NAME="CCJECADD"></A><h1>Sybase SQL Anywhere</h1>
<A NAME="TI323"></A><p>This section describes how to prepare and define a Sybase <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere data source in order
to connect to it using the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
ODBC driver. </p>
<p><img src="images/note.gif" width=17 height=17 border=0 align="bottom" alt="Note"> <span class=shaded>Name change</span> <A NAME="TI324"></A>For versions 6 through 9, the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
database server was called Adaptive Server&#174; Anywhere (ASA).</p>
<A NAME="TI325"></A><p><ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
includes two database servers&#8212;a personal database server
and a network database server. For information about using Sybase
SQL Anywhere, see the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
documentation.</p>
<A NAME="TI326"></A><h2>Supported versions for SQL Anywhere</h2>
<A NAME="TI327"></A><p>The <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere ODBC
driver supports connection to local and remote databases created
with the following:<A NAME="TI328"></A>
<ul>
<li class=fi>PowerBuilder running on your
computer</li>
<li class=ds><ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
version 10.x</li>
<li class=ds>ASA version 9.x</li>
<li class=ds>ASA version 8.x</li>
<li class=ds>ASA version 7.x</li>
<li class=ds>ASA version 6.x</li>
<li class=ds><ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
version 5.x
</li>
</ul>
</p>
<A NAME="TI329"></A><h2>Basic software components for SQL Anywhere</h2>
<A NAME="TI330"></A><p><A HREF="connpbp15.htm#BABCJFGF">Figure 2-5</A> shows
the basic software components required to connect to a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere data source in PowerBuilder.</p>
<A NAME="BABCJFGF"></A><caption><b>Figure 2-5: Components of a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere connection</b></captionls>
<br><img src="images/cnw2any.gif">
<A NAME="CCJDBJBJ"></A><h2>Preparing to use the SQL Anywhere data source</h2>
<A NAME="TI331"></A><p>Before you define and connect to a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
data source in PowerBuilder, follow these steps to prepare the data
source.</p>
<A NAME="TI332"></A><p><img src="images/proc.gif" width=17 height=17 border=0 align="bottom" alt="Steps"> To prepare a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
data source:</p>
<ol><li class=fi><p>Make sure the database file for the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere data source already exists.
You can create a new database by:<A NAME="TI333"></A>
<ul>
<li class=fi>Launching the Create <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
Database utility. You can access this utility from the Utilities
folder for the ODBC interface in the Database profile or Database
painter when PowerBuilder is running on your computer.<br>
This method creates a local <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
database on your computer, and also creates the data source definition
and database profile for this connection. (For instructions, see
the <i>Users Guide</i>
.)<br></li>
<li class=ds>Creating the database some other way, such as with PowerBuilder running
on another user's computer or by using <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere outside PowerBuilder.
(For instructions, see the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere documentation.) 
</li>
</ul>

                      </p></li>
<li class=ds><p>Make sure you have the log file associated with
the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere database so
that you can fully recover the database if it becomes corrupted.</p><p>If the log file for the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
database does not exist, the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
database engine creates it. However, if you are copying or moving
a database from another computer or directory, you should copy or
move the log file with it.</p></li></ol>
<br><A NAME="CCJEAGJH"></A><h2>Defining the SQL Anywhere data source</h2>
<A NAME="TI334"></A><p>When you create a local <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
database, PowerBuilder automatically creates the data source definition
and database profile for you. Therefore, you need only use the following
procedure to define a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
data source when you want to access a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
database not created using PowerBuilder on your computer. </p>
<A NAME="TI335"></A><p><img src="images/proc.gif" width=17 height=17 border=0 align="bottom" alt="Steps"> To define a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
data source for the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
driver:</p>
<ol><li class=fi><p>Select Create ODBC Data Source from the
list of ODBC utilities in the Database Profiles dialog box or the
Database painter.</p></li>
<li class=ds><p>Select User Data Source and click Next.</p></li>
<li class=ds><p>On the Create New Data Source page, select the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere driver and click Finish.</p><p>The ODBC Configuration for <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
dialog box displays:</p><br><img src="images/cn2odbc.gif"><br>
</li>
<li class=ds><p>You must supply the following values:<A NAME="TI336"></A>
<ul>
<li class=fi>Data source name on the ODBC tab page</li>
<li class=ds>User ID and password on the Login tab page</li>
<li class=ds>Database file on the Database tab page
</li>
</ul>

                      </p><p>Use the Help button to get information about fields in the
dialog box. </p></li>
<li class=ds><p>(Optional) To select an ODBC translator to translate
your data from one character set to another, click the Select button
on the ODBC tab.</p><p>See <A HREF="connpbp13.htm#CCJDDEEA">"Selecting an ODBC translator"</A>.</p></li>
<li class=ds><p>Click OK to save the data source definition.</p></li></ol>
<br><A NAME="TI337"></A><h4>Specifying a Start Line value</h4>
<A NAME="TI338"></A><p>When the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
ODBC driver cannot find a running personal or network database server
using the PATH variable and Database Name setting, it uses the commands
specified in the Start Line field to start the database servers. </p>
<A NAME="TI339"></A><p>Specify one of the following commands in the Start Line field
on the Database tab page, where <i>n</i> is the version
of <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere you are using.</p>
<A NAME="TI340"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><tr><th  rowspan="1"  ><A NAME="TI341"></A>Specify
this command</th>
<th  rowspan="1"  ><A NAME="TI342"></A>To</th>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI343"></A><b>dbeng<i>n</i>.exe</b></td>
<td  rowspan="1"  ><A NAME="TI344"></A>Start the personal database server and
the database specified in the Database File box</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI345"></A><b>rteng<i>n</i>.exe</b></td>
<td  rowspan="1"  ><A NAME="TI346"></A>Start the restricted runtime database
server and the database specified in the Database File box</td>
</tr>
</table>
<A NAME="TI347"></A><p>For information on completing the ODBC Configuration For SQL
Anywhere dialog box, see the <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
documentation. </p>
<A NAME="TI348"></A><h2>Support for Transact-SQL special
timestamp columns</h2>
<A NAME="TI349"></A><p>When you work with a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
table in the DataWindow&#174;, Data Pipeline, or Database painter,
the default behavior is to treat any column named <b>timestamp</b> as
a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere Transact-<ACRONYM title = "sequel" >SQL</ACRONYM> special timestamp column.</p>
<A NAME="TI350"></A><h4>Creating special timestamp columns</h4>
<A NAME="TI351"></A><p>You can create a Transact-<ACRONYM title = "sequel" >SQL</ACRONYM> special
timestamp column in a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere table.</p>
<A NAME="TI352"></A><p><img src="images/proc.gif" width=17 height=17 border=0 align="bottom" alt="Steps"> To create a Transact-<ACRONYM title = "sequel" >SQL</ACRONYM> special
timestamp column in a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere table
in PowerBuilder:</p>
<ol><li class=fi><p>Give the name timestamp to any column having
a <b>timestamp</b> datatype that you want treated
as a Transact-<ACRONYM title = "sequel" >SQL</ACRONYM> special timestamp
column. Do this in one of the following ways:<A NAME="TI353"></A>
<ul>
<li class=fi>In the painter &#8211; Select timestamp as the
column name. (For instructions, see the <i>Users Guide</i>
.)</li>
<li class=ds>In a <ACRONYM title = "sequel" >SQL</ACRONYM> CREATE
TABLE statement &#8211; Follow the <A HREF="connpbp15.htm#CCJDBHFJ">"CREATE TABLE example"</A>.
</li>
</ul>

                      </p></li>
<li class=ds><p>Specify <i>timestamp</i> as the
default value for the column. Do this in one of the following ways:<A NAME="TI354"></A>
<ul>
<li class=fi>In the painter &#8211; Select
timestamp as the default value for the column. (For instructions,
see the <i>Users Guide</i>
.)</li>
<li class=ds>In a <ACRONYM title = "sequel" >SQL</ACRONYM> <b>CREATE
TABLE</b> statement &#8211; Follow the <A HREF="connpbp15.htm#CCJDBHFJ">"CREATE TABLE example"</A>.
</li>
</ul>

                      </p></li>
<li class=ds><p>If you are working with the table in the Data
Pipeline painter, select the initial value exclude for the special
timestamp column from the drop-down list in the Initial Value column
of the workspace.</p><p>You must select exclude as the initial value to exclude the
special timestamp column from <b>INSERT</b> or <b>UPDATE</b> statements.</p><p>For instructions, see the <i>Users
Guide</i>
.</p></li></ol>
<br><A NAME="CCJDBHFJ"></A><h4>CREATE TABLE example</h4>
<A NAME="TI355"></A><p>The following <b>CREATE TABLE</b> statement defines
a <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere table named <b>timesheet</b> containing
three columns: <b>employee_ID</b> (<b>integer</b> datatype), <b>hours</b> (<b>decimal</b> datatype),
and <b>timestamp</b> (<b>timestamp</b> datatype
and timestamp default value):</p>
<A NAME="TI356"></A><p><p><PRE> CREATE TABLE timesheet (</PRE><PRE>    employee_ID INTEGER,</PRE><PRE>    hours DECIMAL,</PRE><PRE>    <i>timestamp TIMESTAMP default timestamp</i> )</PRE></p>
<A NAME="TI357"></A><h4>Not using special timestamp columns</h4>
<A NAME="TI358"></A><p>If you want to change the default behavior, you can specify
that PowerBuilder <i>not</i> treat <ACRONYM title = "sequel" >SQL</ACRONYM> Anywhere
columns named <i>timestamp</i> as Transact-<ACRONYM title = "sequel" >SQL</ACRONYM> special timestamp columns. </p>
<A NAME="TI359"></A><p><img src="images/proc.gif" width=17 height=17 border=0 align="bottom" alt="Steps"> To specify that PowerBuilder <i>not</i> treat
columns named <i>timestamp</i> as a Transact-<ACRONYM title = "sequel" >SQL</ACRONYM> special timestamp column:</p>
<ol><li class=fi><p>Edit the Sybase SQL Anywhere section of
the PBODB115 initialization file to change the value of SQLSrvrTSName
from <FONT FACE="Courier New">'Yes'</FONT> to <FONT FACE="Courier New">'No'</FONT>.</p><p>After making changes in the initialization
file, you must reconnect to the database to have them take effect.
See <A HREF="connpbp105.htm#BJBBHCIE">Appendix A, "Adding
Functions to the PBODB115 Initialization File"</A></p></li></ol>
<br><A NAME="TI360"></A><h2>What to do next</h2>
<A NAME="TI361"></A><p>For instructions on connecting to the ODBC
data source, see <A HREF="connpbp84.htm#CCJBAGDB">"Connecting to a database"</A>.</p>

